{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "manual-survey",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "real xxx:Just spilled my glass of lemonade\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "defined \u001b[32mtrait\u001b[39m \u001b[36mUser\u001b[39m\r\n",
       "defined \u001b[32mtrait\u001b[39m \u001b[36mTweeter\u001b[39m\r\n",
       "defined \u001b[32mclass\u001b[39m \u001b[36mverifiedTweeter\u001b[39m\r\n",
       "\u001b[36mreal\u001b[39m: \u001b[32mverifiedTweeter\u001b[39m = ammonite.$sess.cmd1$Helper$verifiedTweeter@32d91e51"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trait User {\n",
    "    def username:String\n",
    "}\n",
    "\n",
    "trait Tweeter {\n",
    "    this :User =>\n",
    "    def tweet(tweetText:String) = println(s\"$username:$tweetText\")\n",
    "}\n",
    "class verifiedTweeter(val username_ :String) extends Tweeter with User {\n",
    "    override def username = s\"real $username_\"\n",
    "}\n",
    "\n",
    "val real = new verifiedTweeter(\"xxx\")\n",
    "\n",
    "real.tweet(\"Just spilled my glass of lemonade\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "through-compatibility",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Scala",
   "language": "scala",
   "name": "scala"
  },
  "language_info": {
   "codemirror_mode": "text/x-scala",
   "file_extension": ".scala",
   "mimetype": "text/x-scala",
   "name": "scala",
   "nbconvert_exporter": "script",
   "version": "2.11.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
